package inherit.practice.demo02.ArrayList03;

public class Test {
    public static void main(String[] args) {
        GirlFriend[] girls = new GirlFriend[4];
        GirlFriend g1 = new GirlFriend("小平",18,"水零零","打游戏");
        GirlFriend g2 = new GirlFriend("小通",19,"水汪汪","睡觉觉");
        GirlFriend g3 = new GirlFriend("小波",20,"亮晶晶","吃饭饭");
        GirlFriend g4 = new GirlFriend("小咯",21,"美丽丽","嘿嘿嘿");
        girls[0] = g1;
        girls[1] = g2;
        girls[2] = g3;
        girls[3] = g4;
        int sum = 0;
        for (int i = 0; i < girls.length; i++) {
            sum = sum + girls[i].getAge();
        }
        int avg = sum/ girls.length;
        System.out.println("平均年龄为:"+avg);
        int count = 0;
        for (int i = 0; i < girls.length; i++) {
            if(girls[i].getAge() < avg){
                count++;
                System.out.println("小于平均年龄的女朋友:"+girls[i].getName());
            }
        }
        System.out.println(count);
    }
}
